class CreateSales < ActiveRecord::Migration
  def change
    create_table :sales do |t|
      t.datetime :sold_at
      t.references :user, index: true
      t.references :product
      t.references :customer, index: true
      t.integer :product_number, default: 1
      t.decimal :sales_reward, default: 0

      t.timestamps null: false
    end
    add_foreign_key :sales, :users
    add_foreign_key :sales, :customers
    add_foreign_key :sales, :products
  end
end
